package com.zj.common;

import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
import java.util.Date;
import java.util.UUID;

public class Utility {
    public static Timestamp getCurrentDate() {
        Date date = new Date();
        Timestamp t = new Timestamp(date.getTime());
        return t;

    }
    public static Boolean strIsEmpty(String str){
        if (str == null || str.equals("")){
            return true;
        }else {
            return false;
        }
    }
    public static String getUUID(){
        String id = UUID.randomUUID().toString();
        String uid = id.replaceAll("-", "");
        return uid;
    }

    public String getRemoteIP(HttpServletRequest request) {
        if (request.getHeader("x-forwarded-for") == null) {
            return request.getRemoteAddr();
        }
        return request.getHeader("x-forwarded-for");
    }
}